# 异常
try:
    print(nu)
except NameError:
    print('上面有异常')

# 捕获多个指定异常
try:
    print(s)
except (NameError,ZeroDivisionError):
    print('上面代码有异常')

# 捕获所有异常
try:
    print(t)
except Exception as f:
    print('上面的代码有问题')

#异常的else
try:
    print(1)
except Exception as f :
    print('以问题')
else:
    print('没有异常')
finally:
    print('有没有都要执行')

#模块导入
# import 模块名
# from 模块名 import 功能名
# from 模块名 import *
# import 模块名 as 别名
# from 模块名 import 功能名 as 别名





# 创建对象
# self指的是调⽤该函数的对象。
# __init__() ⽅法的作⽤：初始化对象。
class washer():
    def __init__(self,width,height):
        self.width=width
        self.height =height
    def __str__(self):
        return '这是海尔洗衣机'

haier=washer(10,20)
print(haier)


# 烤地瓜
class SweetPotato():
    def __init__(self):
        self.cook_time=0
        self.cooke_static='生的'
        self.condiments=[]
    def cook(self,time):
        self.cook_time+=time
        if 0<=self.cook_time <3:
            self.cooke_static='生扥'
        elif 3<=self.cook_time <5:
            self.cooke_static='半生不熟'
        elif 5<=self.cook_time <8:
            self.cooke_static='熟了'
        elif self.cook_time>=8:
            self.cooke_static='糊了'

    def add1(self,cond):
        self.condiments.append(cond)

    def __str__(self):
        return  f'这个地⽠烤了{self.cook_time}分钟, 状态是{self.cooke_static}, 添加的调料有{self.condiments}'

digua1=SweetPotato()
print(digua1)

digua1.cook(2)
digua1.add1('酱油')
print(digua1)

digua1.cook(2)
digua1.add1('酱油')
print(digua1)

digua1.cook(2)
digua1.add1('辣椒⾯⼉')
print(digua1)

# 房子类
